01. Collections

Why data structures?

Data structures are containers that organize and group data together in different ways. When you write code to solve a problem, there will always be data involved—and how you store or structure that data in the computer's memory can have a huge impact on what kinds of things you can do with it and how efficiently you can do those things.

In this section, we'll start out by reviewing some basic data structures that you're probably at least partly familiar with already.

Then, as we go on in the course, we'll consider the pros and cons of using different structures when solving different types of problems.

We'll start with a discussion of a very general structure—a collection.

Collections

Properties of collections

As Brynn discussed, collections:

  • Don't have a particular order (so you can't say "give me the 3rd element in this collection")
  • Don't have to have objects of the same type